package com.zdp.item.rabbit;

import com.zdp.common.constant.RabbitConstants;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author sesshomaru
 * @date 2021/7/11 12:18
 */
@Configuration
public class RabbitItemConfig {

    @Bean
    public DirectExchange appletExchange() {
        return ExchangeBuilder.directExchange(RabbitConstants.APPLET_EXCHANGE).build();
    }

    @Bean
    public Queue freezeStockQueen() {
        return QueueBuilder.durable(RabbitConstants.FREEZE_STOCK_QUEEN).build();
    }

    @Bean
    public Binding freezeStockBinding() {
        return BindingBuilder.bind(freezeStockQueen()).to(appletExchange()).with(RabbitConstants.APPLET_EXCHANGE_WITH_FREEZE_STOCK_QUEEN_KEY);
    }
}
